using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;

public class AddressableCreatEditor 
{

    static string saveAddressablePath => System.Environment.CurrentDirectory + $"/Assets/Scripts/Auto/Engine/AddressFolder.cs";

    static string addressablePath = "Assets/AddressableAssets";

    [MenuItem("Assets/Lr/Save Addressable folder ", false, 10)]
    public static void CreatAddFolder()
    {

        var lastID = saveAddressablePath.LastIndexOf('/');
        var dirPath = saveAddressablePath.Substring(0, lastID);
        var addressCs = CreatAddressableClass(addressablePath);

        if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
        if (File.Exists(saveAddressablePath)) File.Delete(saveAddressablePath);
        File.WriteAllText(saveAddressablePath, addressCs.builder.ToString());

        AssetDatabase.Refresh();
    }

    public static AddressableClass CreatAddressableClass(string path, int order = 0)
    {
        return new AddressableClass(path, order);
    }

}
